package com.example.myui.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;

import com.example.myui.R;


public class ShareDialog extends Dialog {

    private Context mContext;
    private final DisplayMetrics dm;


    public float getPercent() {
        return percent;
    }

    public void setPercent(float percent) {
        this.percent = percent;
    }

    private float percent = 1;

    public int getConView() {
        return conView;
    }

    public void setConView(int conView) {
        this.conView = conView;
    }

    private int conView;

    public int getGRAVITY() {
        return GRAVITY;
    }

    public void setGRAVITY(int GRAVITY) {
        this.GRAVITY = GRAVITY;
    }

    private int GRAVITY;

    public ShareDialog(@NonNull Context context) {
        super(context, R.style.Dialog_Style);
        mContext = context;
        dm = mContext.getResources().getDisplayMetrics();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getView());
        initView();
    }

    private int getView() {
        return conView;
    }

    private void initView() {
        Window window = getWindow();
        WindowManager windowManager = window.getWindowManager();
        Display defaultDisplay = windowManager.getDefaultDisplay();
        window.setGravity(GRAVITY);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.width = (int) (defaultDisplay.getWidth() * 0.8);
        lp.height = (int) (defaultDisplay.getHeight() * 0.8);
//        lp.width = (int) (dm.widthPixels * percent);
//        lp.height = dm.heightPixels;

        window.setAttributes(lp);
//        findViewById(R.id.btn111).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Toast.makeText(mContext,"haha",Toast.LENGTH_SHORT).show();
//            }
//        });

    }
}
